class ScoreBorad extends AcGameObject {
    constructor(playground) {
        super();
        this.playground = playground;
        this.ctx = this.playground.game_map.ctx;

        this.state = null; // xin 胜利 , lose 失败
        
        this.win_img = new Image();
        this.win_img.src = "https://cloud-minapp-39228.cloud.ifanrusercontent.com/1nJUkkmh0boN0FzE.jpg";


        this.lose_img = new Image();
        this.lose_img.src = "https://cloud-minapp-39228.cloud.ifanrusercontent.com/1nJUkkmh0boN0FzE.jpg";
    }

    start(){
    }

    add_listening_events(){
        let that = this;
        var $canvas = this.playground.game_map.$canvas;

        $canvas.on('click',function(e){
            that.playground.hide();
            that.playground.root.menu.show();
        })
    }
    late_update(){
        this.render();
    }

    render(){
        let len = this.playground.height / 2;
        if(this.state === "win"){
            this.ctx.drawImage( this.win_img,this.playground.width / 2 - len/0.46 / 2, this.playground.height / 2 - len / 2, len / 0.46 , len);
        }else if (this.state === "lose"){
            this.ctx.drawImage( this.lose_img,this.playground.width / 2 - len/0.46 / 2, this.playground.height / 2 - len / 2, len / 0.46 , len);
        }
    }

    win(){
        this.state = "win";
        var that = this;
        setTimeout(function(e){
            that.add_listening_events();
        },1000)
    }

    lose(){
        this.state = "lose";
        var that = this;
        setTimeout(function(e){
            that.add_listening_events();
        },1000)
    }
}
